using System;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Coding4Fun.Phone.Controls
{
	public abstract class UserPrompt : ActionPopUp<string, PopUpResult>
	{
		private readonly RoundButton roundButton_0;
		protected internal Action MessageChanged;
		public readonly DependencyProperty IsCancelVisibileProperty = DependencyProperty.Register("IsCancelVisible", typeof(bool), typeof(UserPrompt), new PropertyMetadata(false, new PropertyChangedCallback(UserPrompt.smethod_1)));
		public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(UserPrompt), new PropertyMetadata(""));
		public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(UserPrompt), new PropertyMetadata(""));
		public static readonly DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(UserPrompt), new PropertyMetadata("", new PropertyChangedCallback(UserPrompt.smethod_0)));
		public bool IsCancelVisible
		{
			get
			{
				return (bool)base.GetValue(this.IsCancelVisibileProperty);
			}
			set
			{
				base.SetValue(this.IsCancelVisibileProperty, value);
			}
		}
		public string Value
		{
			get
			{
				return (string)base.GetValue(UserPrompt.ValueProperty);
			}
			set
			{
				base.SetValue(UserPrompt.ValueProperty, value);
			}
		}
		public string Title
		{
			get
			{
				return (string)base.GetValue(UserPrompt.TitleProperty);
			}
			set
			{
				base.SetValue(UserPrompt.TitleProperty, value);
			}
		}
		public string Message
		{
			get
			{
				return (string)base.GetValue(UserPrompt.MessageProperty);
			}
			set
			{
				base.SetValue(UserPrompt.MessageProperty, value);
			}
		}
		protected UserPrompt()
		{
			RoundButton roundButton = new RoundButton();
			this.roundButton_0 = new RoundButton
			{
				ImageSource = new BitmapImage(new Uri("/Coding4Fun.Phone.Controls;component/Media/icons/appbar.cancel.rest.png", 0))
			};
			roundButton.add_Click(new RoutedEventHandler(this.method_6));
			this.roundButton_0.add_Click(new RoutedEventHandler(this.roundButton_0_Click));
			base.ActionPopUpButtons.Add(roundButton);
			base.ActionPopUpButtons.Add(this.roundButton_0);
			this.method_5(this.IsCancelVisible);
		}
		private static void smethod_0(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			UserPrompt userPrompt = (UserPrompt)dependencyObject_0;
			if (userPrompt != null && dependencyPropertyChangedEventArgs_0.get_NewValue() != dependencyPropertyChangedEventArgs_0.get_OldValue() && userPrompt.MessageChanged != null)
			{
				userPrompt.MessageChanged.Invoke();
			}
		}
		private static void smethod_1(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			UserPrompt userPrompt = (UserPrompt)dependencyObject_0;
			if (userPrompt != null && dependencyPropertyChangedEventArgs_0.get_NewValue() != dependencyPropertyChangedEventArgs_0.get_OldValue())
			{
				userPrompt.method_5((bool)dependencyPropertyChangedEventArgs_0.get_NewValue());
			}
		}
		private void method_5(bool bool_3)
		{
			this.roundButton_0.set_Visibility(bool_3 ? 0 : 1);
		}
		private void method_6(object sender, RoutedEventArgs e)
		{
			this.OnCompleted(new PopUpEventArgs<string, PopUpResult>
			{
				Result = this.Value,
				PopUpResult = PopUpResult.Ok
			});
		}
		private void roundButton_0_Click(object sender, RoutedEventArgs e)
		{
			this.OnCompleted(new PopUpEventArgs<string, PopUpResult>
			{
				PopUpResult = PopUpResult.Cancelled
			});
		}
	}
}
